package com.lzy.system.organization.dto;

import com.lzy.utils.validator.group.ServiceInsert;
import com.lzy.utils.validator.group.ServiceUpdate;
import com.lzy.validator.TypeConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * description: SysUserDTO (用户信息)<br>
 * date: 2022-9-29 22:05 <br>
 * author: lcc <br>
 * version: 1.0 <br>
 */
@Data
@ApiModel(value = "用户信息", description = "")
public class SysUserDTO {
    //添加
    @Null(groups = {ServiceInsert.class}, message = "{sysUserDTO.null.id}")
    //修改
    @NotNull(groups = {ServiceUpdate.class}, message = "{sysUserDTO.notNull.id}")
    private Long id;

    //添加
    @NotNull(groups = {ServiceInsert.class}, message = "{public.notNull}")
    @Pattern(regexp = "^[a-zA-Z]\\w{5,31}$", groups = {ServiceInsert.class}, message = "{sysUserDTO.username.Pattern}")
    //修改
    @Null(groups = {ServiceUpdate.class}, message = "{sysUserDTO.null.username}")
    @ApiModelProperty("用户名")
    private String username;

    //添加 和 修改
    @NotNull(groups = {ServiceInsert.class,ServiceUpdate.class},message = "{public.notNull}")
    @Size(groups = {ServiceInsert.class,ServiceUpdate.class},min = 1, max = 255, message = "{sysUserDTO.nickname.Size}")

    @ApiModelProperty("昵称")
    private String nickname;

    //添加 和 修改
    @NotNull(groups = {ServiceInsert.class,ServiceUpdate.class},message = "{public.notNull}")
    @TypeConstraint(groups = {ServiceInsert.class,ServiceUpdate.class},values = {1, 2}, message = "{sysUserDTO.sex.Pattern}")
    @ApiModelProperty("性别")
    private Integer sex;

    //添加 和 修改
    @Pattern(groups = {ServiceInsert.class,ServiceUpdate.class},regexp = "^400[0-9]{7}|^800[0-9]{7}|^1[34578]\\d{9}$|^0[0-9]{2,3}-[0-9]{8}", message = "{sysUserDTO.telephone.Pattern}")
    @ApiModelProperty("电话")
    private String telephone;

    //添加 和 修改
    @Pattern(groups = {ServiceInsert.class,ServiceUpdate.class},regexp = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", message = "{sysUserDTO.email.Pattern}")
    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("状态1启用0锁定")
    private Integer status;

    @ApiModelProperty("头像关联附件id")
    private String headimg;

    @ApiModelProperty("生日")
    private Date birthday;

    @ApiModelProperty("入职日期")
    private Date entry_date;
}

